//
//  Manager.m
//  04-集合2
//
//  Created by 曹曹 on 16/7/7.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "Manager.h"

@implementation Manager
#pragma mark - 初始化
- (instancetype)initWithDictionary:(NSMutableDictionary *)dicntionary {
    self = [super init];
    if (self) {
        _contactDic = dicntionary;
    }
    return self;
}
#pragma mark - 添加联系人
- (void)addContact:(Contact *)contact {
    if ([contact.name length] > 0 && [contact.phoneNumber length] > 0) {
        NSMutableArray *contactArr = [_contactDic objectForKey:contact.groupName];
        if (contactArr == nil) {
            contactArr = [NSMutableArray array];
            [contactArr addObject:contact];
            [_contactDic setObject:contactArr forKey:contact.groupName];
        } else {
            [contactArr addObject:contact];
        }
        NSLog(@"添加%@联系人成功!", contact.name);
    } else {
        NSLog(@"添加%@联系人失败!", contact.name);
    }
}
#pragma mark - 删除分组内的所有人
- (void)deleteGroup:(NSString *)groupName {
    [_contactDic removeObjectForKey:groupName];
}
@end
